<template>
    <div class="setComponent">
        <el-radio-group size="mini" v-model="radio">
            <el-radio-button label="静态数据"/>
            <el-radio-button label="动态数据"/>
        </el-radio-group>
        <div v-if="radio=='静态数据'">
            <div class="form-item">
                <label>标题内容</label>
                <el-button size="mini" @click="butClick(['title', obj.title])">编辑</el-button>
            </div>
        </div>
        <div v-if="radio=='动态数据'">
            <div class="form-item">
                <label>标题属性绑定</label>
                <input type="text" v-model="obj.titleKey">
            </div>
            <div class="form-item">
                <label>接口地址</label>
                <el-input type="textarea" v-model="obj.url"/>
                <!-- <input type="textarea" height="60px" v-model="obj.url"> -->
            </div>
            <el-button @click="submit">提交</el-button>
        </div>
    </div>
</template>
<script>
import Axios from 'axios'
export default {
    name: 'Textarea',
    props: {
        obj: {
            type: Object
        }
    },
    data() {
        return {
            radio: '静态数据'

        }
    },
    methods: {
        butClick(msg) {
            this.$emit('butClick', msg)
        },
        submit() {
            Axios.post(this.obj.url, {})
                .then(res => {
                    console.log(res)
                    this.$set(this.obj, this.obj.titleKey, res.data)
                }).catch(err => {
                    console.log(err)
                })

            console.log(this.obj)
        }
    }
}
</script>

